import java.io.*;
import java.util.*;

public class Test1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n,num,cnt = 0;
        ArrayList<Integer> ve = new ArrayList<>();
        n = sc.nextInt();
        for(int i = 0;i < n;i ++){
            num = sc.nextInt();
            ve.add(num);
        }
        HashSet<Integer> se = new HashSet<>();
        int l = 0,r = 0;
        while(l < ve.size() && r < ve.size()){
            if(se.contains(ve.get(r)) == false){
                se.add(ve.get(r));
                r ++;
                cnt = Math.max(r-l,cnt);
            }else{
                se.remove(ve.get(l));
                l ++;
            }
        }
        System.out.println(cnt);

    }

}
